﻿@using FwProject.Com.Dto
@model List<ShopOrderDetailsDto>
@section styles{
    <style media="print" type="text/css">
        .Noprint {
            display: none;
        }

        .PageNext {
            page-break-after: always;
        }

        * {
            word-wrap: break-word;
            word-break: break-all;
        }

        body, td, th {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 12px;
            color: #1d1007;
            line-height: 20px;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0px;
        }
    </style>
    <link href="/css/print.css" rel="stylesheet" />
}

<!-----------------------------【smsx.cab】打印--------------------------->
<object id="factory" viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
        codebase="/scripts/smsx.cab#Version=6,2,433,70"></object>
<!-----------------------------【smsx.cab】打印--------------------------->
<form name="printformName" id="printformName" action="" method="post">
    <div align="center">
        <div id="printObj" style="width: 190mm" align="center">
            <style>
                table {
                    border-collapse: collapse;
                    border-spacing: 0px;
                }
            </style>

            <!-----------------------------【smsx.cab】打印--------------------------->
            <!--打印前初始化设置-->
            <script language="javascript">

                p_init({
                    portrait: true//true纵向,false横向
                });

            </script>

            <p>
                <input type="button" name="printBtn" class="notprint" value="打印" onclick="pagePrint();" />
            </p>
            <!-----------------------------【smsx.cab】打印--------------------------->
            <table name="mainTable" style="width:100%;height:auto;text-align: center;margin-bottom:0px;margin-top:1px;" border="0">
                <tr>
                    <td align='center' style='width:100%;'>
                        <table cellSpacing=0 cellPadding=0 style="width: 250px">
                            <tr>

                                <td align="left" width="250px" style="font-size: 22px;color:#000000;height: 20px" colspan="4">

                                    订&nbsp; &nbsp; 单 &nbsp; &nbsp; 发 &nbsp; &nbsp; 票
                                </td>
                            </tr>
                            <tr>

                                <td width="250px" style="font-size: 14px;color:#000000;height: 20px" colspan="4">
                                    -------------------------------------
                                </td>
                            </tr>
                            <!-- </tr> -->
                            <tr>
                                <td nowrap="nowrap" align="left" width="250px" style="font-size: 12px;color:#000000;height: 35px" colspan="4">订单号：@ViewBag.OrderNumber</td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" align="left" width="100%" style="font-size: 14px;color:#000000;height: 35px" colspan="4">下单时间：@ViewBag.OrderTime</td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" align="left" width="100%" style="font-size: 14px;color:#000000;height: 35px" colspan="4">收货人：@ViewBag.UserName&nbsp;&nbsp;@ViewBag.Mobile</td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" align="left" width="250px" style="font-size: 14px;color:#000000;height: 35px" colspan="4">收货地址：@ViewBag.Address</td>
                            </tr>
                            <tr>
                                <td width="250px" style="font-size: 14px;color:#000000;height: 20px" colspan="4">
                                    -------------------------------------
                                </td>
                            </tr>
                            <tr>
                                <th align="left" width="140px">商品名称</th>
                                <th align="left" width="30px">数量</th>
                                <th align="left" width="40px">单价</th>
                                <th align="left" width="40px">小计</th>
                            </tr>
                            <tr>
                                <td width="250px" style="font-size: 14px;color:#000000;height: 20px" colspan="4">
                                    -------------------------------------
                                </td>
                            </tr>
                            @{
                                decimal TotalPrice = 0;
                                decimal SumDiscountPrice = 0;
                            }
                            @foreach (var item in Model)
                            {
                                TotalPrice = item.PayPrice * item.ProductCount + TotalPrice;
                                SumDiscountPrice += item.DiscountPrice;
                                <tr>
                                    <td width="140px">@item.ShopName&nbsp;@item.SkuName</td>
                                    <td width="30px">@item.ProductCount</td>
                                    <td width="40px">@item.PayPrice</td>
                                    <td width="40px">@(item.PayPrice * item.ProductCount)</td>
                                </tr>
                            }

                            <tr>
                                <td width="250px" style="font-size: 14px;color:#000000;height: 20px" colspan="4">
                                    -------------------------------------
                                </td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;height: 20px">合计</td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;height: 20px">@Model.Sum(o => o.ProductCount)</td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;height: 20px"></td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;height: 20px">@TotalPrice</td>
                            </tr>
                            <tr>
                                <td width="250px" style="font-size: 14px;height: 20px" colspan="4"><hr style="width:224px;background-color:black" /></td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;">优惠（￥）：</td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;"></td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;"></td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;">@SumDiscountPrice</td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;">实收（￥）：</td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;"></td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;"></td>
                                <td nowrap="nowrap" width="50%" style="font-size: 14px;color:#000000;">@Model.Sum(o => o.PayAmountPrice)</td>
                            </tr>
                            <tr>
                                <td colspan="4" align="center" style="height: 150px">
                                    <img src="@Url.Action("OrderQr",new {orderNumber=ViewBag.OrderNumber})" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    谢谢惠顾，欢迎您下次光临！
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>

    </div>
</form>

@section scripts{
    <script src="~/js/Print.js"></script>
    <script>
        var loadInfo = function () {
            $("#printObj").css({ "width": "270mm" });
            p_init(printInit);
        };
        $(function () {
            loadInfo();
        });

        function pageSet() {
            try {
                p_pagesetup();
            } catch (e) {
                wb.execwb(8, 1);
            }
        }
        function pageView() {
            try {
                p_preview();
            } catch (e) {
                wb.execwb(7, 1);
            }
        }
        function pagePrint() {
            try {
                p_print();
            } catch (e) {
                wb.execwb(6, 6);
            }
        }
    </script>
}

